package test11;

import java.util.*;

class ArrayUtils{

	public static double findMax(double[] arr,int begin, int end) throws IllegalArgumentException{
		double max;
		if(begin>=end)
			throw new IllegalArgumentException("begin:"+begin+" >= "+"end:"+end);
		else if(begin<0){
			throw new IllegalArgumentException("begin:"+begin+" < 0");
		}
		else if(end>arr.length){
			throw new IllegalArgumentException("end:"+end+" > arr.length");
		}else{
			max = arr[begin];
			for (int i = begin+1; i < end; i++) {
				if(arr[i]>max){
					max = arr[i];
				}
			}
		}
		return max;}
}
